$(document).ready(function() {
    $.ajax({
        url: 'MessageShow.do',
        method: 'post',
        contentType: 'application/json', // 这句不加出现415错误:Unsupported Media Type
        dataType:"json",
        success: function(data) {
            if(data!=null){
                var trArr=$("#contentOneTable tr");
                for(i=0;i<trArr.length;i++){
                    if(i!=0){
                        trArr[i].remove();
                    }
                }
                $("#contentOneTable").append(
                    "<tr class=\"turn\">"
                    +"<td>"+data.userEmail+"</td>"
                    +"<td>"+data.name+"</td>"
                    +"<td>"+data.nickname+"</td>"
                    +"<td>"+data.sex+"</td>"
                    +"<td>"+ChangeDateFormat(data.birthDay.toString())+"</td>"
                    // +"<td>"+data.birthDay+"</td>"
                    +"<td>"+data.address+"</td>"
                    +"<td>"+data.phoneNumber+"</td>"
                    +"</tr>"
                );
                if(data.name=="" || data.name==""){
                    $("#next").val("完善信息");
                }else{
                    $("#next").val("修改信息")
                }
            }

        },
        error: function(data) {
            console.log("error...");
        }
    });


    $("#next").click(function(e){
       // url="toModifyAction.action";
       // window.location.href=url;
        url="toModify.do"
        window.location.href=url;
    });
    $("#exit").click(function(){
        url="cleanSession.do";
        window.location.href=url;
    })

    function ChangeDateFormat(jsondate) {
        jsondate = jsondate.replace("/Date(", "").replace(")/", "");

        if (jsondate.indexOf("+") > 0) {
            jsondate = jsondate.substring(0, jsondate.indexOf("+"));
        } else if (jsondate.indexOf("-") > 0) {
            jsondate = jsondate.substring(0, jsondate.indexOf("-"));
        }
        //alert(jsondate);
        var date = new Date(parseInt(jsondate, 10));
        //alert(date.getHours());
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        return date.getFullYear() + "-" + month + "-" + currentDate;
    }
})